﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Master/Default.Master" AutoEventWireup="true" CodeBehind="addRemoveProfessor.aspx.cs" Inherits="PointTracker.addRemoveProfessor" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolderHead" runat="server">
    <script language="javascript" type="text/javascript">
        // Verifies that all the necessary fields for adding a professor are filled in        
        function VerifyFields() {
            var errors = false;
            var list = "";

            document.getElementById("Errors").setAttribute("class", "error");
            list += "<ul>";

            if(document.getElementById("<%= TextBoxFname.ClientID %>").value == "") {
                list += "<li>The first name field cannot be empty</li>";
                errors = true;
            }
            if (document.getElementById("<%= TextBoxLname.ClientID %>").value == "") {
                list += "<li>The last name field cannot be empty</li>";
                errors = true;
            }
            if (document.getElementById("<%= TextBoxEmail.ClientID %>").value == "") {
                list += "<li>The e-mail field cannot be empty</li>";
                errors = true;
            }
            if (document.getElementById("<%= TextBoxPassword.ClientID %>").value == "" || document.getElementById("<%= TextBoxVpassword.ClientID %>").value == "") {
                list += "<li>The password fields cannot be empty</li>";
                errors = true;
            }
            if (document.getElementById("<%= TextBoxPassword.ClientID %>").value != document.getElementById("<%= TextBoxVpassword.ClientID %>").value) {
                list += "<li>The password fields must match</li>";
                errors = true;
            }

            document.getElementById("Errors").innerHTML = list;

            if(errors) {
                document.getElementById("<%= TextBoxPassword.ClientID %>").value = "";
                document.getElementById("<%= TextBoxVpassword.ClientID %>").value = "";
            }

            document.getElementById("Errors").innerHTML += "</ul>";
            return !errors;
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolderBody" runat="server">
    <fieldset>
    <legend>Add a Professor</legend>
    <div id="Errors"></div>
    <dl id="addRemoveForm">
        <dt><label>First Name:</label></dt>
        <dd><asp:TextBox ID="TextBoxFname" runat="server"></asp:TextBox></dd>
        <dt><label>Last Name:</label></dt>
        <dd><asp:TextBox ID="TextBoxLname" runat="server"></asp:TextBox></dd>
        <dt><label>E-mail:</label></dt>
        <dd><asp:TextBox ID="TextBoxEmail" runat="server"></asp:TextBox></dd>
        <dt><label>Password:</label></dt>
        <dd><asp:TextBox ID="TextBoxPassword" TextMode="Password" runat="server"></asp:TextBox></dd>
        <dt><label>Verify Passowrd:</label></dt>
        <dd><asp:TextBox ID="TextBoxVpassword" TextMode="Password" runat="server"></asp:TextBox></dd>
    </dl>
    
    <asp:Button ID="ButtonAddProfessor" OnClick="AddProfessor" OnClientClick="return VerifyFields();" runat="server" Text="Add Professor"/>
    </fieldset>
</asp:Content>
